From: Jo-Philipp Wich Date: Fri, 28 Jun 2019 11:09:56 +0000 (+0200) Subject: scripts: add usign secret to public key converter X-Git-Tag: v1~103 X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=9fb96ae8ae3585339e0cb2019dd2f7bb40d8eea6;p=buildbot.git scripts: add usign secret to public key converter Signed-off-by: Jo-Philipp Wich --- diff --git a/scripts/sec2pubkey.pl b/scripts/sec2pubkey.pl new file mode 100755 index 0000000..60fff38 --- /dev/null +++ b/scripts/sec2pubkey.pl @@ -0,0 +1,25 @@ +#!/usr/bin/env perl + +use strict; +use MIME::Base64; + +my @lines = (-t STDIN) ? () : <>; + +if (@lines == 0) { + die "Usage: $0 < key.sec > key.pub\n"; +} + +my $seckey = decode_base64(pop @lines); +my $comment = shift(@lines) || "untrusted comment: secret key"; + +chomp($comment); + +$comment =~ s/\bsecret key$/public key/; + +if (length($seckey) != 104) { + die "Unexpected secret key length\n"; +} + +my $pubkey = encode_base64(substr($seckey, 0, 2) . substr($seckey, 32, 8) . substr($seckey, 72), ""); + +printf "%s\n%s\n", $comment, $pubkey;